import { createRouter, createWebHashHistory } from 'vue-router'
import Community from '../src/components/nav/navTylir/secondaryMenu/Community.vue'
import Person from '../src/components/nav/navTylir/secondaryMenu/Navperson.vue'
import main from "../src/main.vue"
import Login from '../src/components/index/index.vue'
import register from '../src/components/index/register.vue'

const routes = [
  //主页
  {
    path: "/",
    name:"main",
    components:{default:main,contain:() => import("../src/components/swipers/notice.vue")},
    children:[
     
      //默认初始通知
       {
        path: "",
        components:{default:main,contain:() =>import("../src/components/swipers/notice.vue")},
       },
       //维修人员
       {
          path: "navaccendant",
          name:"navaccendant",
          children:[
            {
              path:"planwork",
              name:"navaccendant-Planwork",
              components:{default:main,contain:import("../src/components/nav/nav-accendant/planwork.vue")},
              // component: import("../src/components/nav/nav-accendant/planwork.vue")
            },
            {
              path:"treework",
              name:"navaccendant-Treework",
              components:{default:main,contain:import("../src/components/nav/nav-accendant/treework.vue")},
              // component: import("../src/components/nav/nav-accendant/treework.vue")
            }
    ]
       },
       //社区管理员
       {
        path: "/navtylir",
        name:"navtylir",
        children:[
          {
            path:"Community",
            name:"navtylir-Community",
            components:{default:main,contain:Community},
          },
          {
            path:"person",
            name: "navtylir-Person",
            components:{default:main,contain:Person},
          },
          {
            path:"plant",
            name: "navtylir-Plant",
            components:{default:main,contain:import("../src/components/nav/navTylir/secondaryMenu/Plant.vue")},
            // component:import("../src/components/nav/navTylir/secondaryMenu/Plant.vue")
          },
          {
            path:"plan",
            name: "navtylir-Plan",
            components:{default:main,contain:import("../src/components/nav/navTylir/secondaryMenu/Plan.vue")},
            // component:import("../src/components/nav/navTylir/secondaryMenu/Plan.vue")
          },
          {
            path:"insertplan",
            name: "navtylir-InsertPlan",
            components:{default:main,contain:import("../src/components/nav/navTylir/secondaryMenu/InsertPlan.vue")},
            // component:import("../src/components/nav/navTylir/secondaryMenu/InsertPlan.vue")
          },
        ]
       },
       //管理员
       {
        path: "/navadmin",
        name:"navadmin",
        children:[
          {
            path:"treeplan",
            name:"navadmin-Treeplan",
            components:{default:main,contain:import("../src/components/nav/admin/admin-treePlan.vue")},
            // component: import("../src/components/nav/admin/admin-treePlan.vue")
          },
          {
            path:"community",
            name:"navadmin-Community",
            components:{default:main,contain:import("../src/components/nav/admin/community-admin.vue")},
            // component: import("../src/components/nav/admin/community-admin.vue")
          },
          {
            path:"detail",
            name:"navadmin-Detail",
            components:{default:main,contain:import("../src/components/nav/admin/community-detail.vue")},
            // component: import("../src/components/nav/admin/community-detail.vue")
          },
          {
            path:"notice",
            name:"navadmin-Notice",
            components:{default:main,contain:import("../src/components/nav/admin/notice-issue.vue")},
            // component: import("../src/components/nav/admin/notice-issue.vue")
          },
          {
            path:"allplan",
            name:"navadmin-Allplan",
            components:{default:main,contain:import("../src/components/nav/admin/admin-plan.vue")},
            // component: import("../src/components/nav/admin/admin-plan.vue")
          }
        ]
       },
       //修改个人信息
       {
        path: "/updateuser",
        name: "updateuser",
        components:{default:main,contain:import("../src/components/modifaction/information.vue")},
        // component: import("../src/components/modifaction/information.vue")
      },
      //公告
      {
        path: "/hotpoint",
        name: "hotpoint",
        components:{default:main,contain:import("../src/components/nav/nav-static/hotpoint.vue")}
      }
    ]
  },
  //登录
  {
    path: "/login",
    name:"login",
    component:Login
  },
  //注冊
  {
    path:"/register",
    name:"register",
    component:register
  }

  ]


const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
      /*
          createWebHashHistory
            http://localhost:8080/#/home
            http://localhost:8080/#/about
            原理： a 锚点 
          createWebHistory:
             http://localhost:8080/home
             http://localhost:8080/about
           这种方式需要后台做重定向，否则会 404
              原理： H5 pushState()
      */
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
  })

  export default router